package com.example.project.business.aop_demo;

import java.lang.reflect.Method;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;

@Aspect
//@Component
public class SomeServiceAspect {

    //声明： 切点（ 连接点1 || 连接点2 ....）    
    @Pointcut("execution(* *..SomeService.print*(..))")
    public void someServicePointcut()
    {
    }
    
    // 声明： 通知（切点1 || 切点2 .....）    
    @Around("someServicePointcut()")
    public Object someServiceExcuteAdvice(ProceedingJoinPoint pjp) throws Throwable
    {
        Object obj = null;
        // 获取连接点的方法签名对象
        MethodSignature joinPointObject = (MethodSignature) pjp.getSignature();
        // 连接点对象的方法
        Method method = joinPointObject.getMethod();
        
        System.out.println("SomeServiceAspect advice invoke");
        obj = pjp.proceed();
        return obj;
    }
}
